<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form ref="dataForm" size="mini" :model="listQuery" label-position="right" label-width="auto">
        <div class="lineBox">
          <el-form-item label="全文检索：" prop="content">
            <el-input v-model="listQuery.content" size="mini" placeholder="" style="width: 120px" />
          </el-form-item>
        </div>

        <div class="lineBox">
          <el-button size="mini" type="primary" @click="qwjsFilter">
            全文检索
          </el-button>
        </div>
      </el-form>
    </div>

    <div class="myTable" style="min-height: 600px">
      <el-collapse v-model="activeNames" accordion @change="handleChange">
        <el-collapse-item v-for="(item,index) in list" :key="index" :name="index">
          <template slot="title">
            <div class="no-wrap-ellipsis">
              <span v-html="item.highlight.content[0]" />
            </div>
          </template>
          <div>
            <div v-html="lightTxt" />
            <div>
              档号：<el-link class="always-underlined" :href="`/dashboard/docview?id=${id}`" target="_blank"
                type="primary">
                {{ dh }}
              </el-link>
            </div>
          </div>
        </el-collapse-item>
      </el-collapse>
    </div>

    <div>
      <pagination size="mini" :page-sizes="[10]" :total="total" :page.sync="listQuery.page"
        :limit.sync="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" @pagination="getqwjs" />
    </div>
  </div>
</template>

<script>
import { artApi } from "@/api/art";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination

export default {
  components: { Pagination },

  data() {
    return {
      id: null,
      dh: null,
      lightTxt: null,
      activeNames: null,



      tableKey: 0,
      list: [],
      total: 0,
      listLoading: false,
      listQuery: {
        mj: "",
        pageNumber: 1,
        page: 1,
        limit: 10,

        content: "",

      },
      data: [],
    };
  },

  mounted() { },

  created() {
    this.qwjsFilter();
  },
  methods: {

    async handleChange(val) {
      this.lightTxt = null
      this.dh = ""
      console.log(this.list[val]);
      const response = await artApi("getfulltxtById", { "_id": this.list[val]._id, "searchContent": this.listQuery.content });
      this.lightTxt = response.data.highlight.content[0]
      this.dh = response.data._source.dh
      this.id = response.data._source.id
      console.log(response.data.highlight.content[0])
      this.activeNames = val
    },
    skipxiugai(row, index) {
      this.$router.push("/dashboard/eid?id=" + row.id);
    },

    // 修改跳转
    skip(row, index) {
      this.$router.push("/dashboard/save?id=" + row.id);
    },

    skipdocview(row, index) {
      this.$router.push("/dashboard/docview?id=" + row.id);
    },

    async skip1(row, index) {
      this.$router.push("/modelsknowledge/physical?dh=" + row.dh);
    },






    qwjsFilter() {
      this.list = [];
      this.total = 0;
      this.isText = true;
      this.listQuery.page = 1;
      this.getqwjs();
    },

    async getqwjs() {
      this.list = [];
      this.listLoading = true;
      const response = await artApi("getDocumentQwjsPage", this.listQuery);
      if (response.code == 200) {
        this.list = response.data.resultList;
        this.total = response.totalCount;
        // this.type = response.type
        //   // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false;
        }, 1.5 * 1000);
      }
    },

    // 数据列表

  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-checkbox__label {
  font-size: 12px;
}

.no-wrap-ellipsis {
  white-space: nowrap; /* 防止文本换行 */
  overflow: hidden; /* 超出的部分隐藏 */
  text-overflow: ellipsis; /* 使用省略号表示被隐藏的文本 */
  display: block; /* 让 span 表现得像块级元素，以支持宽度控制 */
  max-width: 100%; /* 确保最大宽度不超过父容器的宽度 */
}

.demo-image__preview {
  float: left;
  margin-left: 5px;
}
.demonstration {
  font-size: 12px;
  color: #333;
  font-weight: normal;
}
</style>
